<%@ page import="java.util.List" %>
<%@ page import="java.util.Enumeration" %><%--
  Created by IntelliJ IDEA.
  User: HP
  Date: 2024/8/7
  Time: 9:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>列表图书</title>
</head>
<body>
   <h1> 1. pageContext作用域 <hr></h1>
    <%
        List<String> books = (List<String>)pageContext.getAttribute("books");
        out.println("【pageContex作用域】：" + books);
    %>
   <h1> 2. request作用域 <hr></h1>
   <%
       books = (List<String>)request.getAttribute("books");
       out.println("【request作用域】：" + books);
       request.removeAttribute("books");        // 移除这个请求的属性books
   %>
   <h1> 3. session作用域 <hr></h1>
   <%
       books = (List<String>)session.getAttribute("books");
       String id = session.getId();
       out.println("id:" + id  + "<br>");
       out.println("【session作用域】：" + books);
       session.removeAttribute("books");        // 移除session的属性值
   %>
   <h1> 4. application作用域 <hr></h1>
   <%
       books = (List<String>)application.getAttribute("books");
       Enumeration<String> attributeNames = application.getAttributeNames();
       out.println("当前内置的application的属性名：<hr>" );
       while(attributeNames.hasMoreElements()){
           String s = attributeNames.nextElement();
           out.println("属性名：" + s + "<br>");
       }
       out.println("【application作用域】：" + books);
       application.removeAttribute("books");        // 移除application作用域中的一个属性
   %>
</body>
</html>
